<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        添加库存
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div class="x-body">
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>库存查询</cite></a>
            <a><cite>添加库存</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>


    <div class="main_box">
        <div class="panel-heading">
            <h2>增加物料</h2>
        </div>
    </div>

    <form class="layui-form x-center" id“="app">

        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>物料号</label>
                <div class="layui-input-block">
                    <input autocomplete="off"  type="text" lay-verify="required" class="layui-input" name="partsNum" id="partsNum"
                           placeholder="物料号">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>计量单位</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" lay-verify="required" name="partsUnits" id="partsUnits"
                           placeholder="计量单位">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>配件名称</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" lay-verify="required" name="partsName" id="partsName"
                           placeholder="配件名称">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>配件规格</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" lay-verify="required" name="specification" id="specification"
                           placeholder="配件规格">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">适用品牌</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" name="applicableModels" id="applicableModels"
                           placeholder="适用品牌">
                </div>
            </div>
            <div class="layui-form-item">

                <label class="layui-form-label"><span style="color: red">*</span>适用梯型</label>
                <div class="layui-input-block">
                    <select name="applicableElevatorType" id="applicableElevatorType" lay-filter="getdianti" lay-verify="required">
                        <option value="">请选择</option>
                        <option value="3">通用</option>
                        <option value="0">客梯</option>
                        <option value="1">扶梯</option>
                        <option value="2">货梯</option>
                    </select>
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>安装指导价</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" lay-verify="required|number" name="installGuideprice" id="installGuideprice"
                           placeholder="安装指导价">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red">*</span>指导价</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" lay-verify="required|number" name="guideprice" id="guideprice" placeholder="指导价">
                </div>
            </div>
            <h3 style="text-align: left;">备注：</h3>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  type="text" class="layui-input" name="partsRemark" id="partsRemark" placeholder="备注">
                </div>
            </div>
            <h3 style="text-align: left;">物料图册： (格式 jpg、jpeg、png、gif。)</h3>
            <div class="layui-upload" style="margin-top: 8px;">

                <button type="button" class="layui-btn" id="upImage">上传图片</button>
                <input  autocomplete="off"  class="layui-upload-file" type="file" accept="" name="file">
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="demo1" width="250" height="250">
                    <p id="demoText"></p>
                </div>

            </div>

            <div style="text-align: center" class="layui-form-item">
                <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                    添加
                </button>
            </div>

            <br> <br> <br>
        </div>
    </form>


</div>
</body>

<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script type="text/javascript" src="../../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    //配置插件目录
    layui.config({
        base: '../../js/'
        , version: '1.0'
    });
</script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form', 'upload'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>
    layui.use(['form', 'layer', 'upload'],
        function () {
            var form = layui.form;
            var layer = layui.layer;
            var upload = layui.upload;
            var picUrl = null ;
            var oldUrl = null;



            var index = null;
            var uploadInst = upload.render({
                elem: '#upImage'
                ,url: baseHead+'other/fileUpload1' //改成您自己的上传接口
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                    index = layer.load();
                }
                ,done: function(res){
                    //如果上传成功
                    layer.close(index);
                    if(res.code == 0){
                        picUrl = res.data;
                        console.log(picUrl);
                    }
                    else {
                        layer.alert("上传失败，请重新上传！");
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });



            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;

                    form.partsImg=picUrl;
                    form.userId = $userId;
                    let request = {
                        url: 'kf/parts/addParts',
                        data: form,
                        method: "post",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.location.reload();
                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;


                });
        });


    const vm = new Vue({
        el: "#app",
        created() {

        },
        computed: {},
        methods: {},


    });

</script>


</html>
